# -*- coding: utf-8 -*-
from django import forms
from congreso.trabajos.models import *
from django.utils.translation import ugettext_lazy as _
from congreso.countries.models import Country
from django.conf.global_settings import LANGUAGES
import datetime

## CUSTOM CHOICES
DISSERTATION_TYPE = (
    ("", ""),
    ("Oral", "Oral"),
    ("Poster", "Poster"),
)

## DISSERTATIONS

class DissertationForm(forms.Form):
    
    date = forms.DateField(label=_('Date'), initial=datetime.date.today, widget=forms.DateInput(\
        attrs={'size':'9','class':'date-pick'}), help_text='Format: YYYY-MM-DD')
    author_first_name = forms.CharField(label=_('First Name'), max_length=30, help_text=\
        _('maximum 50 characters'), error_messages={'max_length':\
        _('has exceeded the maximum characters allowed')}, widget=forms.TextInput(attrs=\
        {'size':'30','onblur':'this.value=this.value.toUpperCase()'}))
    author_last_name = forms.CharField(label=_('Last Name'), max_length=50, help_text=\
        _('maximum 50 characters'), error_messages={'max_length':\
        _('has exceeded the maximum characters allowed')}, widget=forms.TextInput(attrs=\
        {'size':'30','onblur':'this.value=this.value.toUpperCase()'}))
    author_email = forms.EmailField(label=_('Email'), max_length=50, help_text=\
        _('maximum 50 characters'), error_messages={'max_length':\
        _('has exceeded the maximum characters allowed')}, widget=forms.TextInput(attrs=\
        {'size':'30','onblur':'this.value=this.value.toLowerCase()'}))
    author_phone = forms.CharField(required=False, label=_('Phone'), max_length=15, help_text=\
        _('maximum 15 characters'), error_messages={'max_length':\
        _('has exceeded the maximum characters allowed')}, widget=forms.TextInput(attrs=\
        {'size':'15'}))
    filiation = forms.CharField(label=_('Filiation'), max_length=50, help_text=\
        _('maximum 50 characters'), error_messages={'max_length':\
        _('has exceeded the maximum characters allowed')}, widget=forms.TextInput(attrs=\
        {'size':'30','onblur':'this.value=this.value.toUpperCase()'}))
    filiation_country = forms.ModelChoiceField(label=_('Coutry of Filiation'), queryset=\
        Country.objects.all(), empty_label='')
    presenter = forms.CharField(required=False, label=_('Presenter'), max_length=50, help_text=\
        _('maximum 50 characters'), error_messages={'max_length':\
        _('has exceeded the maximum characters allowed')}, widget=forms.TextInput(attrs=\
        {'size':'30','onblur':'this.value=this.value.toUpperCase()'}))
    main_author = forms.CharField(label=_('Main Author'), max_length=50, help_text=\
        _('maximum 50 characters'), error_messages={'max_length':\
        _('has exceeded the maximum characters allowed')}, widget=forms.TextInput(attrs=\
        {'size':'30','onblur':'this.value=this.value.toUpperCase()'}))
    registered = forms.BooleanField(required=False, label=_('Registered'), help_text='')
    area = forms.ModelChoiceField(required=False, queryset=Area.objects.all(), empty_label='',
        label=_('Area'), widget=forms.Select())
    sub_area = forms.IntegerField(required=False, label=_('SubArea'))
    language = forms.ChoiceField(label=_('Dissertation language'), initial='en',
        choices=LANGUAGES)
    title = forms.CharField(label=_('Title'), max_length=50, help_text=_('maximum 50 characters'),
        error_messages={'max_length':_('has exceeded the maximum characters allowed')},
        widget=forms.TextInput(attrs={'size':'30','onblur':'this.value=this.value.toUpperCase()'}))
    dissertation = forms.CharField(label=_('Dissertation'), max_length=10000, help_text=\
        _('maximum 10000 characters'), error_messages={'max_length':\
        _('has exceeded the maximum characters allowed')}, widget=forms.Textarea)
    dissertation_type = forms.ChoiceField(label=_('Dissertation type'),
        choices=DISSERTATION_TYPE)
    
class CommentForm(forms.ModelForm):
    
    class Meta:
        model = Comment
        exclude = ('date_time','dissertation','author')
    
    comment = forms.CharField(label=_('Comment'), widget=forms.Textarea(attrs=\
        {'rows':'2', 'cols':'104'}))
